import java.nio.channels.ScatteringByteChannel;
import java.util.Arrays;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        char[] arr = {'c','d','a','a','b'};
        Arrays.sort(arr,0,arr.length);
        System.out.println(arr);
    }


    public static String fun3(String s){
        int[] arr = new int[127];
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length()-1; i++) {
            char ch = s.charAt(i);
            if(arr[ch] == 0){
                arr[ch] = 1;
               sb.append(ch);
           }
        }
        return sb.toString();
    }

    public static void main12(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()){
            String str= scanner.nextLine();
            String str1 = fun3(str);
            System.out.println(str1);
        }
    }


    public  int fun2(){
        int y = 0;
        try {
            System.out.println(10/2);
            return ++y;
        }catch (ArithmeticException e){
            e.printStackTrace();
        }finally {
            System.out.println("hahaha");
           // return ++y;
        }
        return -1;
    }
    public static void main11(String[] args) {
        Test test = new Test();
        int x = test.fun2();
        System.out.println(x);
    }


    public static void fun(int x){
        try {
            if(x==1){
                throw new RuntimeException("x=1");
            }
        }catch (RuntimeException e){
            e.printStackTrace();
        }
    }

    public static void main10(String[] args) {
        fun(1);
        System.out.println("haha");
    }

    public static boolean ist(char s){
        if(s >= 'a' && s <= 'z' || s >= '1' && s <= '9'){
            return true;
        }
        return false;
    }
    public static boolean ish(String s){
        int x = 0;
        int y = s.length()-1;
        while (x<y){
            while (x<y && !ist(s.charAt(x))){
                x++;
            }
            while (x<y && !ist(s.charAt(y))){
                x--;
            }
            if(s.charAt(x) != s.charAt(y)){
                return false;
            } else {
                x++;
                y--;
            }
        }
        return true;
    }
    public static void main9(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String str1 = str.toLowerCase();
        boolean b = ish(str1);
        System.out.println(b);
    }

    public static void main8(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        /*String[] strings = str.split(" ");
        int x = strings.length;
        String str1 = strings[x-1];
        System.out.println(str1+str1.length());*/
        String str1 = str.trim();
        int x = str1.lastIndexOf(' ');
        String str2 = str1.substring(x+1);
        System.out.println(str2+str2.length());
    }

    public static void main7(String[] args) {
        String str = "abcdabc";
        int[] hash = new int[26];
        for (int i = 0; i < str.length(); i++) {
            char x = str.charAt(i);
            hash[x-97]++;
        }
        for (int i = 0; i < str.length(); i++) {
            char x = str.charAt(i);
            if(hash[x-97] == 1){
                System.out.println(x);
                break;
            }
        }
    }

    public static void main6(String[] args) {
        String str = "abca";
        char x = str.charAt(1);
        int a = str.indexOf('b');
        int b = str.lastIndexOf('a');
        System.out.println(x);
        System.out.println(a);
        System.out.println(b);
    }

    public static void main5(String[] args) {
        char[] chars = {'a','b','c'};
        char[] chars1;
        chars1 = new char[]{1,2,3,'a'};
        char[] chars2 = new char[10];
        System.out.println(chars);
    }

    public static void main4(String[] args) {
        String str = "   ab  cd    ";//去除字符串两端的空格
        System.out.println(str.trim());
        System.out.println(str);
    }

    public static void main3(String[] args) {
    String str = "abcdefg";
    String str1 = str.substring(3);//从字符串下标为3的位置，截取全部
    String str2 = str.substring(3,5);//从字符串下标为3的位置，截取到字符串下标为5的位置，不包括5
        System.out.println(str1);
        System.out.println(str2);
    }

    public static void main2(String[] args) {
        String str = "129.168.1.1";
        String log = "1,2.3!4";
        String[] strings1 = str.split("\\.");
        String[] strings2 = str.split("\\.",2);//最多分两组
        String[] strings3 = log.split(",|\\.|!");//如果有多个分隔符，用"|"作为连字符
        for (String s:strings1) {
            System.out.println(s);
        }
        for (String s:strings2) {
            System.out.println(s);
        }
        for (String s:strings3) {
            System.out.println(s);
        }
        System.out.println(str);
    }
    public static void main1(String[] args) {
        String str = "abcdefabcdef";
        char[] chars = str.toCharArray();
        System.out.println(chars);
        System.out.println(Arrays.toString(chars));
        String str1 = str.replace('a','m');
        String str2 = str.replaceAll("a","w");
        String str3 = str.replaceFirst("a","d");
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);

    }
}
